/*
 * @Author: firesky
 * @Date: 2020-10-10 10:38:48
 * @LastEditTime: 2020-12-22 11:01:52
 * @LastEditors: firesky
 */
// import { FQXMenu } from '../api/login'
export const common = {
  inject: ['globalDb'], // 页面公用db  this.globalDb.db
  data() {
    return {
      calHeight: 0,
      tableHeight: '', // 表格高度

      fstatus: '', // 状态
      // 下拉列表
      statusList: [
        {
          fstatus: 0,
          fname: '全部'
        },
        {
          fstatus: 1,
          fname: '未审'
        },
        {
          fstatus: 2,
          fname: '已审'
        }
      ],

      ffustatus: '', // 状态
      // 下拉列表
      fustatusList: [
        {
          ffustatus: 0,
          fname: '全部'
        },
        {
          ffustatus: 1,
          fname: '未复审'
        },
        {
          ffustatus: 2,
          fname: '已复审'
        }
      ],

      fcategory: '', // 分类参数
      // 下拉列表
      fcategoryList: [
        {
          fname: '一类参数',
          finterid: 'IA'
        },
        {
          fname: '二类参数',
          finterid: 'IB'
        },
        {
          fname: '三类参数',
          finterid: 'IC'
        }
      ],
      // 常规主燃油
      // 磨合调整过程
      cgzry: {
        mhtzTableData: [
          { ffuhe: '25%', fpower: 0, fsjtime: '↑20', fyxtime: '20', fyh: '195', fmaxyh: '208.65', fryxhl: 0 },
          { ffuhe: '50%', fpower: 0, fsjtime: '↑30', fyxtime: '30', fyh: '192', fmaxyh: '205.44', fryxhl: 0 },
          { ffuhe: '75%', fpower: 0, fsjtime: '↑30', fyxtime: '30', fyh: '190', fmaxyh: '201.4', fryxhl: 0 },
          { ffuhe: '100%', fpower: 0, fsjtime: '↑50', fyxtime: '60', fyh: '185', fmaxyh: '194.25', fryxhl: 0 },
          { ffuhe: '85%', fpower: 0, fsjtime: '↓10', fyxtime: '20', fyh: '197', fmaxyh: '206.85', fryxhl: 0 },
          { ffuhe: '110%', fpower: 0, fsjtime: '↑20', fyxtime: '10', fyh: '198', fmaxyh: '207.9', fryxhl: 0 }
        ],
        // 内部提交和FAT过程
        nbtjTableData: [
          { ffuhe: '25%', fpower: 0, fsjtime: '↑15', fyxtime: '30', fyh: '195', fmaxyh: '0', fryxhl: 0 },
          { ffuhe: '50%', fpower: 0, fsjtime: '↑15', fyxtime: '30', fyh: '192', fmaxyh: '0', fryxhl: 0 },
          { ffuhe: '75%', fpower: 0, fsjtime: '↑15', fyxtime: '30', fyh: '190', fmaxyh: '0', fryxhl: 0 },
          { ffuhe: '85%', fpower: 0, fsjtime: '↑15', fyxtime: '60', fyh: '197', fmaxyh: '0', fryxhl: 0 },
          { ffuhe: '100%', fpower: 0, fsjtime: '↑15', fyxtime: '60', fyh: '185', fmaxyh: '0', fryxhl: 0 },
          { ffuhe: '110%', fpower: 0, fsjtime: '↑15', fyxtime: '30', fyh: '198', fmaxyh: '0', fryxhl: 0 }
        ]
      },
      // 常规气缸油
      // 磨合调整过程
      cgqg: {
        mhtzTableData: [
          { ffuhe: '25%', fpower: 0, fsjtime: '↑20', fyxtime: '30', fyh: 1.4, fryxhl: 0 },
          { ffuhe: '50%', fpower: 0, fsjtime: '↑30', fyxtime: '30', fyh: 0, fryxhl: 0 },
          { ffuhe: '75%', fpower: 0, fsjtime: '↑30', fyxtime: '30', fyh: 0, fryxhl: 0 },
          { ffuhe: '100%', fpower: 0, fsjtime: '↑50', fyxtime: '60', fyh: 0, fryxhl: 0 },
          { ffuhe: '85%', fpower: 0, fsjtime: '↓10', fyxtime: '20', fyh: 0, fryxhl: 0 },
          { ffuhe: '110%', fpower: 0, fsjtime: '↑20', fyxtime: '10', fyh: 0, fryxhl: 0 }
        ]
      }
    }
  },
  async created() {
    await this.getTableHeight()
  },
  mounted() {
    // this.getFQXMenu()
    // console.log(this.globalDb.db, ' common.js')
    // console.log(this.globalDb.fname, ' common.js')
    // 挂载window.onresize事件(动态设置table高度)
    const _this = this
    window.onresize = () => {
      if (_this.resizeFlag) {
        clearTimeout(_this.resizeFlag)
      }
      _this.resizeFlag = setTimeout(() => {
        _this.getTableHeight()
        _this.resizeFlag = null
      }, 100)
    }
  },
  methods: {
    // async getFQXMenu() {
    //   try {
    //     const res = await FQXMenu({
    //       db: this.globalDb.db,
    //       loginname: decodeURIComponent(this.globalDb.fname)
    //     })
    //     this.globalDb.menusList = res.Data
    //     console.log(res, '  res5555555')
    //   } catch (error) {
    //     console.log(error)
    //   }
    // },
    // 计算table高度(动态设置table高度)
    getTableHeight() {
      const tableH = 194// 距离页面下方的高度
      const skHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
      const tableHeightDetil = skHeight - tableH
      // alert(skHeight, ' skHeight  ', tableHeightDetil, '   tableHeightDetil')
      // if (tableHeightDetil <= 300) {
      //   this.tableHeight = 500
      // } else {
      // this.tableHeight = window.innerHeight - tableH
      this.tableHeight = tableHeightDetil
      // }
      // console.log(this.tableHeight, ' this.tableHeight')
    },
    tableHeaderStyle({ row, column, rowIndex, columnIndex }) {
      // console.log('tableHeaderStyle')
      return 'background-color: #909399ba;color:#fff;font-weight:400;overflow: hidden;text-overflow: ellipsis; white-space: nowrap;'
    }
  }
}
